package ch10_numbers;

import java.util.Calendar;
import java.util.Date;
import static java.lang.Math.*;


public class Main {
	public static void main(String[] args) {
//		System.out.println(String.format("%,.2f", 1234.56789));
//		printCharTable();
		
//		testDateFormat();
		int x = 5;
		int y = (int)pow(x, 2);
		testCalendar();
	}
	
	private static void testCalendar() {
		Calendar c = Calendar.getInstance();
		
		Date date = new Date();
		c.setTime(date);
		long ms = c.getTimeInMillis();
		ms += 4*60*60*1000;
		
		System.out.println(String.format("Date before: %tc", date));
		c.setTimeInMillis(ms);
		System.out.println(String.format("Date after: %tc", c.getTime()));
		
		int n = 30;
		c.roll(c.DATE, n);
		System.out.println(String.format("Date after roll: %tc", c.getTime()));
		
//		c.add(c.DATE, n);
//		System.out.println(String.format("Date after add: %tc", c.getTime()));
		
		c.set(c.DATE, n);
		System.out.println(String.format("Date after set: %tc", c.getTime()));
	}
	
	private static void testDateFormat() {
		System.out.println(String.format("tc: %tc\ntA: %<tA\ntB: %<tB\nday is %<td", new Date()));
	}
	
	private static void printCharTable() {
		System.out.println("Character table:");
		for (char c = 0; c < 256; ++c) {
			System.out.print(c + " ");
			
			if (c % 8 == 0)
				System.out.print("  ");
			
			if (c % 32 == 0)
				System.out.println();
		}
	}
}
